@extends('common.layouts')

@section("content")
<div class="content-wrap">
        <div class="main">
            <div class="container-fluid">
                <div class="main-content">
                        @include('common.message')
                    <div class="row">
                        <div class="col-lg-9">
                            <div class="card alert">
                                <div class="card-header">
                                    <h4>@yield('headerTitle',"用户列表")</h4>
                                </div>
                                <div class="card-body">
                                    <table class="table table-responsive">
                                        <thead>
                                            <tr>
                                                <th>id</th>
                                                <th>userName</th>
                                                <th>created_at</th>
                                                <th>性别</th>
                                                <th>添加时间</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @foreach ($userList as $user)
                                                <tr>
                                                <th scope="row">{{ $user->id }}</th>
                                                <td>{{ $user->userName }}</td>
                                                <td><span class="badge badge-primary">{{ $user->created_at }}</span></td>
                                                <td>{{ $user->gender!=null?(($user->gender==1)?"女":"男"):"人妖" }}</td>
                                                <td class="color-primary">{{ $user->created_at }}</td>
                                                <td> 
                                                    <a href="detail/{{ $user->id }}">详情 |</a>
                                                    <a href="update/{{ $user->id }}">修改 |</a>
                                                    <a href="delete/{{ $user->id }}" >删除</a>
                                                </td>
                                            </tr>
                                            @endforeach
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                    {{-- 分页 --}}
                    <div>
                        <div class="pull-right">
                            {{ $userList->render() }}
                        </div>
                    </div>
                </div>
            </div><!-- /# container-fluid -->
        </div><!-- /# main -->
    </div><!-- /# content wrap -->
@stop
@section('js')
    {{-- <script>
       function deleteUser(id){
            if(confirm("确定要删除id为{"+id+"}的{{ $user->userName }}吗?")){
                $.ajax({
                    url:"delete/"+id,
                    success:function(result){
                        // 转为json对象
                        var resultJson=$.parseJSON(result)
                        console.log(resultJson);
                        // $.each(resultJson, function(i,item) {
                        //     alert(item.i)
                        // });
                        // location.href="userindex";
                    }

                });
            }
        }
    </script> --}}
@endsection